<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>提货信息</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="/static/wx/lib/sui/sm.min.css">
    <link rel="stylesheet" href="/static/wx/lib/sui/sm-extend.min.css">
    <link rel="stylesheet" href="/static/wx/css/reset.css">
    <link rel="stylesheet" href="/static/wx/css/main.css">
    <link rel="stylesheet" href="/static/wx/css/public_main.css">
</head>

<body>
<div class="page-group">
    <div class="page page-current" id="commodityInfo">
        <!-- 主内容 -->
        <div class="content">
            <div class="bs-box">
                <div class="bs-box-content">
                    <div class="bs-box-inner">
                        <div class="bs-box-content-item size-m">
                            <div>提货是否需要支付其他费用</div>
                            <div>
                                <div class="row round">
                                    <div class="col-50"><label class="size-65"><input type="radio" name="is_pay" value="1"
                                                                                      {if(isset($info))}{if($info.is_pay == 1)}checked="checked"{/if}{/if}> <i></i>
                                        参与
                                    </label></div>
                                    <div class="col-50"><label class="size-65"><input type="radio" name="bid" name="is_pay" value="2"
                                                                                      {if(isset($info))}{if($info.is_pay == 2)}checked="checked"{/if}{/if}> <i></i>
                                        不参与
                                    </label></div>
                                </div>
                            </div>
                            <div>
                                <div>
                                    <textarea class="size-m" type="text" id="pay_result" placeholder="请填写需要支付的详细费用，以免产生纠纷" style="width: 100%;">{$info.pay_result | default=null}</textarea>
                                </div>
                            </div>
                        </div>
                        <div class="bs-box-content-item">
                            <p class="size-m">提货详细说明</p>
                            <div>
                                <textarea class="size-m" type="text" id="bol_info" placeholder="请填写提货前所需的资料和相关手续的详细要求" style="width:100%">{$info.bol_info | default=''}</textarea>
                            </div>
                        </div>
                        <div class="bs-box-content-item width-link size-m border-b-none">
                            <div>提货地址</div>
                            <div><input placeholder="请选择省市区" id="bol_address" value="{$info.bol_province} {$info.bol_city} {$info.bol_town}"></div>
                        </div>
                        <div class="bs-box-content-item" style="padding: 0px;">
                            <div><input type="text" placeholder="详细门牌地址" class="size-m" name="bol_address_detail" value="{$info.bol_address_detail | default=''}"></div>
                        </div>
                        <div class="bs-box-content-item">
                            <p class="size-m">联系人</p>
                            <div><input type="text" placeholder="请填写姓名" class="size-m" name="bol_linkman" value="{$info.bol_linkman | default=''}"></div>
                        </div>
                        <div class="bs-box-content-item">
                            <p class="size-m">手机号</p>
                            <div><input type="text" placeholder="请填写手机号" class="size-m" name="bol_phone" value="{$info.bol_phone | default=''}"></div>
                        </div>
                        <div class="bs-box-content-item width-link">
                            <p class="size-m">提货时限</p>
                            <div>
                                <input type="text" placeholder="" class="size-m" id="bol_days" {if isset($info.bol_days)}value="竞价拍卖后{$info.bol_days}天内"{else /}value=""{/if} style="font-size:.65rem;width:150px;text-align:right;">
                                <span class="size-m">提货</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="btn-box">
                <div class="my-btn">
                    <input type="hidden" id="policy_num" value="{$info.policy_num | default = ''}">
                    <input type="hidden" id="i_id" value="{$info.i_id | default = ''}">
                    <span class="active" id="submit">保存</span>
                </div>
            </div>
        </div>
    </div>
</div>
<script type='text/javascript' src='/static/wx/lib/sui/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/static/wx/lib/sui/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/static/wx/lib/sui/sm-extend.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/static/wx/lib/sui/sm-city-picker.min.js' charset='utf-8'></script>
<script>
    $(function () {
        var arr = [];
        getArr();
        function getArr() {
            $.ajax({
                type: 'POST',
                url: "{:url('/wx/Insurant/getBolDays')}",
                data: {},
                dataType: 'json',
                async: false,
                success: function (data) {
                    arr = data.arr;
                }
            });
        }

        $('#submit').on('touchend',function(){
            var i_id = $('#i_id').val();
            var policy_num = $('#policy_num').val();
            var is_pay = $('input[name="is_pay"]:checked').val();
            var pay_result = $('#pay_result').val();
            var bol_info = $('#bol_info').val();
            var bol_address = $('#bol_address').val();
            var bol_address_detail = $('input[name="bol_address_detail"]').val();
            var bol_days = $('#bol_days').val();
            var bol_linkman = $('input[name="bol_linkman"]').val();
            var bol_phone = $('input[name="bol_phone"]').val();
            if (is_pay == null) {
                $.alert('请选择是否参与');
                return;
            }
            if (pay_result == "") {
                $.alert('请填写需要支付的详细费用');
                return;
            }
            if (bol_info == "") {
                $.alert('请填写提货详细说明');
                return;
            }
            if (bol_address.length == 0) {
                $.alert('请选择省市区');
                return;
            }
            if (bol_address_detail.length == 0) {
                $.alert('请填写详细地址');
                return;
            }
            if (bol_linkman.length == 0) {
                $.alert('请填写联系人');
                return;
            }
            if (bol_phone.length == 0) {
                $.alert('请填写手机号');
                return;
            }
            if (bol_days == 0) {
                $.alert('请填写提货时限');
                return;
            }
            $.ajax({
                url:'/wx/insurant/saveBolInfo',
                type:'post',
                dataType:'json',
                data:{
                    'is_pay':is_pay,
                    'pay_result':pay_result,
                    'bol_info':bol_info,
                    'bol_address':bol_address,
                    'bol_address_detail':bol_address_detail,
                    'bol_days':bol_days,
                    'bol_linkman':bol_linkman,
                    'bol_phone':bol_phone,
                    'i_id':i_id,
                    'now_status':3
                },
                success:function (data) {
                    if(data.code ==200){
                        $.alert('修改成功');
                        window.location.href = '/wx/insurant/returnEdit?policy_num='+policy_num;
                    }else{
                        $.alert(data.msg);
                    }
                }
            });
        });
        $("#bol_days").picker({
            toolbarTemplate: '<header class="bar bar-nav">\
                                <button class="button button-link pull-right close-picker">确定</button>\
                                <h1 class="title">选择看货要求</h1>\
                                </header>',
            cols: [
                {
                    textAlign: 'center',
                    values: arr
                }
            ]
        });
        $("#bol_address").cityPicker({
            toolbarTemplate: '<header class="bar bar-nav">\
                    <button class="button button-link pull-right close-picker">确定</button>\
                    <h1 class="title">提货地址</h1>\
                    </header>'
        });

    });

</script>
</body>

</html>